<template>
	<Tabs>
		<TabPane label="会员分组">
			<SuperTable
		    	ref="table"
		    	path="API_MEMBER_GROUP_LISTS"
		    	:columns="columns"
		    	:params="params"
		    	:loading="false"
		    >
		    	<Button type="primary" slot="header-left" @click="handleGoEdit()">新增会员分组</Button>
		    	
		        <div slot-scope="{ row }" slot="action">
		        	<Button type="primary" size="small" :disabled="row.id == 1" @click="handleGoEdit({id: row.id})">配置</Button>
	        		<Poptip
				        confirm
				        transfer
				        placement="left"
				        title="是否确认删除此分组？"
				        @on-ok="handleDelete(row.id)"
				    >
				        <Button type="error" size="small" :disabled="row.id == 1">删除</Button>
				    </Poptip>
		        </div>
		    </SuperTable>
		</TabPane>
	</Tabs>
</template>

<script>
import Util from '@/libs/util.js';
import SuperTable from '@/components/SuperTable.vue';
export default {
	name: 'memberGroup',
	components: {
		SuperTable
	},
	data() {
		return {
			params: {
				order: 0,
				page: 1,
				limit: 10
			},
			columns: [
                {
                    title: '分组名称',
                    key: 'name',
                    maxWidth: 210
                },
                {
                    title: '分组说明',
                    key: 'description'
                },
                {
                    title: '分组会员人数',
                    key: 'member_num',
                    maxWidth: 210,
                    align: "center"
                },
                {
                    title: '分组类型',
                    key: 'type_text',
                    maxWidth: 180,
                    align: "center"
                },
                {
                    title: '操作',
                    slot: 'action',
                    align: "center",
                    width: 120
                },
			]
		}
	},
	methods: {
		// 编辑
		handleGoEdit(query) {
			this.$router.push({name: 'user_retail_group_edit', query});
		},
		// 删除
		handleDelete(id) {
			Util.ajax.post(this.API['API_MEMBER_GROUP_DESTROY'], {id: id}).then((res) => {
				this.$Message.success('删除成功');
				this.$refs.table.init();
			}).catch(() => {
				
			})
		}
	}
}
</script>